import { POST } from '../axios.config.js'

const base = window.config.ip
const lib = `${base}/rcdg-zbkh/index-library`

const URLS = {
  listIndexLibrary: `${lib}/listIndexLibrary`, // 获取指标库列表
  listSysIndexLibrary: `${lib}/listSysIndexLibrary`, // 获取系统指标库列表
  saveIndexOption: `${lib}/saveIndexOption`, // 保存指标库指标信息
  delIndexOption: `${lib}/delIndexOption`, // 删除指标库指标信息
  saveImportModelIndex: `${lib}/saveImportModelIndex`, // 模型指标导入
}

// 获取模型列表
export const listIndLibs = ({ optionName, categoryId, isSystem, indType }, currentPage = 1, pageSize = 10) =>
  POST(isSystem ? URLS.listSysIndexLibrary : URLS.listIndexLibrary, {
    param: {
      optionName,
      optionType: categoryId,
      type: indType,
    },
    currentPage,
    pageSize,
  })

// 保存模型信息
export const saveIndLibInfo = (
  { optionType, optionName, codeDesc, keyWord, optionDetailList, scoreDTO, shareScoreList, status },
  codeNumber
) =>
  POST(URLS.saveIndexOption, {
    optionType,
    codeNumber,
    optionName,
    codeDesc,
    keyWord,
    optionDetailList,
    scoreDTO,
    shareScoreList,
    status,
  })

// 删除模型
export const delLibInd = codeNumber =>
  POST(URLS.delIndexOption, {
    oneParam: codeNumber,
  })

// 删除模型
export const saveLibImport = (modelId, indexId, source, optionList) =>
  POST(URLS.saveImportModelIndex, {
    modelId,
    indexId,
    source,
    optionList,
  })
